<template>
  <div class="collaborationManage">
    <!-- <div class="tree">
      <TreeSearch :treeTitle="treeTitle"></TreeSearch>
    </div> -->
    <!-- 标签-->
    <el-tabs v-model="activeName" type="card">
      <el-tab-pane name="first">
        <div slot="label" class="pageHeader">涉案人员管理</div>
      </el-tab-pane>
    </el-tabs>
    <div class="container">
      <!-- 搜索查询 -->
      <div class="searchBar" v-show="showSearch">
        <div class="searchForm">
          <el-form
            :model="queryParams"
            ref="queryForm"
            size="small"
            :inline="true"
            label-width="80px"
          >
            <el-form-item label="涉案人姓名:" prop="name">
              <el-input
                v-model.trim="queryParams.name"
                placeholder="请输入涉案人员姓名"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="涉案人身份证号:" prop="zjh">
              <el-input
                v-model.trim="queryParams.zjh"
                placeholder="请输入涉案人员证件号"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="案件名称:" prop="caseName">
              <el-select
                v-model.trim="queryParams.caseName"
                filterable
                placeholder="请选择案件名称"
                clearable
                class="input"
              >
                <el-option
                  v-for="item in cases"
                  :key="item.id"
                  :label="item.caseName"
                  :value="item.caseName"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
        <div class="searchButtons">
          <el-button class="searchButton" @click="handleQuery">搜索</el-button>
          <el-button class="resetButton" @click="resetQuery">重置</el-button>
        </div>
      </div>
      <!-- 新增、批量删除、导入、导出 -->
      <!-- <div class="addDeleteBar">
        <el-button
          class="addButton"
          icon="el-icon-plus"
          v-hasPermi="['collManage:add']"
          @click.native="handleAdd"
          >新增</el-button
        >
        <el-button
          @click="handleDelete"
          :class="!multiple ? 'deleteButton' : 'allDeleteButton'"
          :disabled="multiple"
          icon="el-icon-delete"
          v-hasPermi="['collManage:del']"
          >批量删除</el-button
        >
      </div> -->
      <!-- 表单选择清空 -->
      <div class="tableSelectArea">
        <div>
          <div class="iconInfo el-icon-info"></div>
          <span class="infoText">已选择</span>
          <span class="infoText infoActive" v-text="selectedNum"></span>
          <span class="infoText">项</span>
          <span class="infoButton" @click="clearSelect">清空</span>
        </div>
        <right-toolbar
          :showSearch.sync="showSearch"
          @queryTable="getList"
        ></right-toolbar>
      </div>
      <div class="table">
        <!-- TODO：这个高度是怎么算的 -->
        <el-table
          ref="multipleTable"
          class="tableArea"
          v-loading="loading"
          :data="collList"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="50" align="center">
          </el-table-column
          >8/
          <el-table-column
            type="index"
            label="序号"
            width="70"
            align="center"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
          <el-table-column
            prop="applicationName"
            label="申请人姓名"
            width="70"
            align="center"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
          <el-table-column
            label="申请人身份证号"
            :show-overflow-tooltip="true"
            align="left"
            width="100"
            prop="applicationZjh"
          >
          </el-table-column>
          <el-table-column
            prop="applicationTel"
            width="100"
            label="申请人联系方式"
            align="left"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            prop="applicationRelation"
            label="与涉案人关系"
            align="center"
            width="100"
            :show-overflow-tooltip="true"
          >
            <template v-slot="scope">
              <dict-tag
                :options="dict.type.relation_type"
                :value="scope.row.applicationRelation"
              ></dict-tag>
            </template>
          </el-table-column>
          <el-table-column
            label="涉案人姓名"
            prop="name"
            :show-overflow-tooltip="true"
            align="left"
            width="100"
          >
          </el-table-column>
          <el-table-column
            prop="zjh"
            width="200"
            label="涉案人身份证号"
            align="left"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            prop="tel"
            width="150"
            label="涉案人电话"
            align="left"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            label="人员类型"
            :show-overflow-tooltip="true"
            align="center"
            width="130"
            prop="tagType"
          >
            <template slot-scope="scope">
              <dict-tag
                :options="dict.type.tag_type"
                :value="scope.row.tagType"
              ></dict-tag>
            </template>
          </el-table-column>
          <el-table-column
            prop="caseName"
            label="案件名称"
            width="200"
            align="left"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            prop="personJudgmentLossAmount"
            label="损失金额"
            width="200"
            align="left"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            prop="residenceAddress"
            label="户籍地址"
            width="250"
            align="left"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            prop="wholeLiveAddress"
            label="居住地址"
            align="left"
            width="250"
            :show-overflow-tooltip="true"
          ></el-table-column>

          <el-table-column
            label="操作"
            width="250px"
            align="left"
            fixed="right"
          >
            <template slot-scope="scope">
              <div class="tableButtonArea">
                <!-- <el-button
                  type="text"
                  class="operationButton"
                  @click="handleUpdate(scope.row)"
                  >修改</el-button
                > -->
                <el-button
                  type="text"
                  class="operationButton"
                  @click="handleDetail(scope.row)"
                  >详情</el-button
                >
                <el-button
                  type="text"
                  class="operationButton"
                  @click="handleUpdate(scope.row)"
                  v-hasPermi="['tag:add']"
                  >标注类型</el-button
                >
                <el-button
                  type="text"
                  class="operationButton"
                  v-hasPermi="['tag:delete']"
                  @click="handleDelete(scope.row)"
                  >删除标注</el-button
                >
                <div class="buttonLine"></div>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="tableFooter">
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>
    <!-- 涉案人员新增修改模态框 -->
    <addModal
      :modalType.sync="modalType"
      @fatherMethod="fatherMethod"
    ></addModal>
    <!-- 删除标注模态框 -->
    <deleteTag
      :tagType.sync="tagType"
      :id.sync="id"
      @fatherMethod="fatherMethod"
    ></deleteTag>
    <!-- 涉案人员详情模态框 -->
    <detailModal
      :detailId.sync="detailId"
      :detailCaseId.sync="detailCaseId"
    ></detailModal>
  </div>
</template>

<script>
// 引入接口
import { listInvoved, editTag } from "@/api/invovedPerson/invovedPerson.js";
import addModal from "./components/addModal.vue";
import deleteTag from "./components/deleteTag.vue";
import detailModal from "./components/detailModal.vue";
import TreeSearch from "../../layout/components/TreeSearch/index.vue";
import { fatherMethod } from "../../utils/commonMethods";
import { MODALTYPE, PAGESIZE, PAGENUM, ROLETYPE } from "../../utils/variable";
import { getCaseList } from "@/api/caseManage/case";
// 引入模态框组件
export default {
  dicts: ["process_result", "tag_type", "relation_type"],
  // 声明组件
  components: { addModal, deleteTag, detailModal, TreeSearch },
  data() {
    return {
      treeTitle: "涉案人员管理",
      activeName: "first",
      modalType: "",
      dialog: false,
      selectedNum: 0,
      id: 0,
      // 案件
      cases: [],
      // 搜索的日期范围
      dateRange: [],
      ids: [],
      // 非多个禁用
      multiple: true,
      detailId: 0,
      // 查询参数
      queryParams: {
        pageNum: PAGENUM,
        pageSize: PAGESIZE,
        // deptId:'',
        deptName: "",
        caseName: "",
        taskName: "",
      },
      detailCaseId: 0,
      tagType: "",
      loading: false,
      // 案件总条数
      total: 0,
      //  显示搜索条件
      showSearch: true,
      // 协同案件列表
      collList: [],
    };
  },
  computed: {
    dynamicWidth() {
      if (
        this.$store.state.user.roles == ROLETYPE[0] ||
        this.$store.state.user.roles == ROLETYPE[1] ||
        this.$store.state.user.roles == ROLETYPE[2]
      ) {
        return "350px ";
      } else {
        return "100px";
      }
    },
  },
  created() {
    this.getList();
    this.getCase();
  },
  mounted() {},
  methods: {
    fatherMethod,
    /** 查询案件列表 */
    getList() {
      this.loading = true;
      this.queryParams.oucode = this.$store.state.user.oucode;
      listInvoved(this.queryParams)
        .then((response) => {
          this.collList = response.rows;
          this.total = response.total;
          this.loading = false;
        })
        .catch(() => {});
    },
    // 案件名称列表
    getCase() {
      let params = {
        oucode: this.$store.state.user.oucode,
      };
      getCaseList(params).then((response) => {
        this.cases = response.data;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.selectedNum = selection.length;
      this.ids = selection.map((item) => item.id);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    //清空列表选择
    clearSelect() {
      this.$refs.multipleTable.clearSelection();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.modalType = MODALTYPE["新增"];
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.tagType = MODALTYPE["修改"];
      this.id = row.id;
    },
    /** 详情按钮操作 */
    handleDetail(row) {
      this.detailCaseId = row.caseId;
      this.detailId = row.id;
      console.log(row);
      this.id = row.id;
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      let num = this.selectedNum;
      console.log(row.id);
      if (row.id) {
        num = 1;
      }
      this.$modal
        .confirm("是否确认删除" + num + "人员标注")
        .then(function () {
          return editTag(row.id, 0);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除标注成功");
        })
        .catch(() => {});
    },
  },
};
</script>
<style lang='scss' scoped >
@import "../../assets/styles/variables.scss";
.collaborationManage {
  height: 100%;
  .tableFooter {
    text-align: right;
    justify-content: flex-end;
    // margin-top: 25px;
    margin-right: 35px;
    // width: 100%;
    ::v-deep .btn-prev {
      color: #d4d3d3 !important;
      background-color: #fff;
      border: 1px solid #d4d3d3;
    }
    ::v-deep .btn-next {
      color: #d4d3d3 !important;
      background-color: #fff;
      border: 1px solid #d4d3d3;
    }
    ::v-deep .el-pager li {
      background-color: #fff;
      border: 1px solid #d4d3d3;
      font-size: 12px;
      font-family: $font-family;
      font-weight: 400;
      color: #5a5b5d;
    }
  }
  .el-form-item__label {
    font-family: $font-family;
    font-weight: $form-label-font-weight;
    font-size: $form-label-font-size;
    color: $form-label-color;
  }

  .el-input__inner {
    font-size: $form-content-font-size;
    font-family: $font-family;
    font-weight: $form-label-font-weight;
    // color: #AEAFB0;
  }
}
.el-tabs--card > .el-tabs__header .el-tabs__nav {
  border: 0px;
}
::v-deep .el-tabs--card .el-tabs__header {
  background-color: #e4e7ed;
}
::v-deep.el-tabs--card .el-tabs__header .el-tabs__item {
  border-radius: 10px solid black;
  background-color: #fff;
  font-size: 14px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  color: #053ef6;
  line-height: 48px;
  margin-top: 0;
}
.el-tabs--card {
  margin-left: 10px;
  border: 0px !important;
}

.tree {
  // width: 250px;
  flex-shrink: 0;
  height: 100%;
  overflow: auto;
  border-radius: 7px 0px 0px 7px;
  background-color: #fff;
  border-right: 2px solid #e6e6e8;
  border-top: 1px solid #f1f1f3;
  border-left: 1px solid #f1f1f3;
  border-bottom: 1px solid #f1f1f3;
}
</style>
